//
// Created by root on 2020/6/3.
//

#include "MakePacket.h"

#include "muduo/net/Endian.h"

std::string MakePacket::MakePacketStr(uint32_t _iProtocolId, const std::string &_str) {
    uint32_t iSize = sizeof(_iProtocolId) + _str.size();
    iSize = muduo::net::sockets::hostToNetwork32(iSize);
    _iProtocolId = muduo::net::sockets::hostToNetwork32(_iProtocolId);
    std::string sPakcet;
    sPakcet.append((char*)&iSize, sizeof(iSize));
    sPakcet.append((char*)&_iProtocolId, sizeof(_iProtocolId));
    sPakcet.append(_str);
    return sPakcet;
}
